package com.yc.yyds.servlet;

import com.yc.yyds.Bean.Result;
import com.yc.yyds.biz.BizException;
import com.yc.yyds.biz.UserLoginBiz;
import com.yc.yyds.util.ToJsonUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UserUpdateMsgServlet", value = "/UserUpdateMsgServlet.s")
public class UserUpdateMsgServlet extends HttpServlet {
    UserLoginBiz biz = new UserLoginBiz();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String username = request.getParameter("username");
        String pwd = request.getParameter("pwd");
        String phone = request.getParameter("phone");
        String email = request.getParameter("email");
        String image = request.getParameter("image");
        String gender = request.getParameter("gender");
        String userid = request.getParameter("userid");
        Result result;
        try {
            biz.save(username,pwd,phone,email,image,gender,userid);
            result = new Result(1,"修改成功",null);
            ToJsonUtil.toJson(response,result);

        } catch (BizException e) {
            e.printStackTrace();
            result = new Result(0,e.getMessage(),null);
            ToJsonUtil.toJson(response,result);
        }


    }
}
